package com.hnl.action.attachment;

import java.io.IOException;
import java.io.Writer;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.LoggerFactory;

import com.hnl.core.aware.HNLTalentAware;
import com.hnl.dao.AttachmentDAO;
import com.hnl.dao.DAOException;
import com.hnl.dao.HNLDAOFactory;

@SuppressWarnings("serial")
public class DeleteAttachment extends HttpServlet implements HNLTalentAware {
	public static final org.slf4j.Logger LOG = LoggerFactory
			.getLogger(DeleteAttachment.class);

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		Writer writer = resp.getWriter();
		try {
			String attachmentId = req.getParameter(ATTRIBUTE_ATTACHMENT_ID);
			AttachmentDAO attachmentDAO = HNLDAOFactory.getDAOFactory(
					HNLDAOFactory.HNLDAOFACTORY).getAttachmentDAO();
			
			attachmentDAO.deleteAttachement(Integer.valueOf(attachmentId));
		} catch (DAOException e) {
			LOG.error("error laoding Talent", e);
		} finally {
			writer.close();
		}
	}
}
